<script src="/javascripts/tbeditor.js"></script>
<h2>编辑<%= te_title %></h2>
<a href="javascript:add_item()" class="btn btn-success btn-sm">新增条目</i></a>
<form>
    <table><tbody>
        <tr>
            <% te_fields.forEach(function(field) { %>
                <th class="te-field"><%= field %></th>
            <% }); %>
            <th>操作</th>
        </tr>
        <% if(te_items!=undefined) te_items.forEach(function(item,i) { %>
            <tr id="id-<%=i%>">
                <% te_fields.forEach(function(field) { %>
                    <td><input type="text" class="form-control te-item" value="<%= item[field] %>"/></td>
                <% }); %>
                <td style="min-width:50px">
                    <a href="javascript:remove_item(<%=i%>)" class="btn btn-danger btn-sm">删除</a>
                </td>
            </tr>
        <% }); %>
    </tbody></table>
    <a href="javascript:editor_save('<%=te_target%>','<%=te_title%>')" class="btn btn-primary">保存</a>
    <span>离开本页面前请务必保存，否则更改不会生效！</span>
</form>
<p id="te_tip" style="display:none"></p>